package com.two.shopping.mapper;

import com.two.shopping.pojo.Admin;
import com.two.shopping.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface ILoginMapper {
    //用户登录
    @Select("select *from user where username=#{username} and password=#{password}")
    User userLogin(User user) throws Exception;

    @Select("select *from admin where admin_name=#{adminName} and admin_password=#{adminPassword}")
    Admin adminLogin(Admin admin) throws Exception;

    //用户注册
    @Insert("insert into user (username,password,phone_number,create_time,update_time ) values(#{username},#{password},#{phoneNumber},#{createTime},#{updateTime})")
    void createUser(User user) throws Exception;

    //检查是否重名(手机号和用户名)
    @Select("select * from user  where phone_number=#{phoneNumber} or username=#{username}")
    User selectPhoneNumberOr1(User user) throws Exception;
    @Select(("select * from user where id=#{id}"))
    User selectId(Integer id);

}
